package com.ass.rocketmq.utils;

import com.ass.rocketmq.constant.MQTopic;
import org.apache.rocketmq.common.message.Message;

public class MessageUtil {

    public static Message buildMessage(String keys, String messageBody,
                                       MQTopic mqTopic, String active){
        Message message = new Message();
        message.setTopic(active + "_" + mqTopic.topic);
        message.setTags(active + "_" + mqTopic.tag);
        message.setBody(messageBody.getBytes());
        message.setKeys(keys);
        message.setDelayTimeLevel(mqTopic.delayTimeLevel);
        return message;
    }

    //异常消息主题
    public static Message buildErrorMessage(String keys, String messageBody,String active){
        Message message = new Message();
        MQTopic mqTopic = MQTopic.ERROR;
        message.setTopic(active + "_" + mqTopic.topic);
        message.setTags(active + "_" + mqTopic.tag);
        message.setBody(messageBody.getBytes());
        message.setKeys(keys);
        message.setDelayTimeLevel(mqTopic.delayTimeLevel);
        return message;
    }


}
